<?php


namespace common\validate;


class Invoice extends BaseValidate
{
    public $rule = [];

    // Fields 验证场景定义
    public function sceneFields()
    {
        return $this;
    }

    // Find 验证场景定义
    public function sceneFind()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array');
    }

    // Select 验证场景定义
    public function sceneSelect()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array')
            ->append('param.page', 'array');
    }

    // Create 验证场景定义
    public function sceneCreate()
    {
        return $this->append('data.name', 'require|max:128')
            ->append('data.code', 'max:128');
    }

    // Update 验证场景定义
    public function sceneUpdate()
    {
        return $this->append('data.id', 'require')
            ->append('data.name', 'max:128')
            ->append('data.code', 'max:128');
    }

    // Delete 验证场景定义
    public function sceneDelete()
    {
        return $this->append('param.filter', 'require');
    }

    // UploadInvoice 验证场景定义
    public function sceneUploadInvoice()
    {
        return $this
            ->append("data.order_id", "require|integer")
            ->append("data.receivable_id", "require|integer")
            ->append("data.invoice_number", "require|max:255")
            ->append("data.ship_number", "max:255")
            ->append("data.invoice_type", "require")
            ->append("data.attached_media", "array");
    }

    // EnsureInvoice 验证场景定义
    public function sceneEnsureInvoice()
    {
        return $this->append("param.filter", "require|array");
    }

    // GetCustomerInvoiceApplyList 验证场景定义
    public function sceneGetCustomerInvoiceApplyList()
    {
        return $this->append("param", "require|array")
            ->append("page", "array");
    }

    // UploadInvoiceCustomerInvoiceApply 验证场景定义
    public function sceneUploadInvoiceCustomerInvoiceApply()
    {
        return $this
            ->append("data.id", "require|integer")
            ->append("data.invoice_number", "require|max:255")
            ->append("data.ship_number", "max:255")
            ->append("data.invoice_type", "require")
            ->append("data.attached_media", "array");
    }
}
